//
//  Singleton.m
//  UI13_课堂练习
//
//  Created by Maxdong on 14-12-11.
//  Copyright (c) 2014年 lanou3g.com 蓝欧科技. All rights reserved.
//

#import "Singleton.h"

static Singleton *share= nil;

@implementation Singleton

- (void)dealloc
{
    [super dealloc];
}


+(instancetype)shareInstance
{
    
    //第一种单例安全
//    @synchronized(self)
// {
//    if ( !share )
//    {
//        share = [[Singleton alloc] init];
//    }
// }
//    return share;
//}
    
    //第二种单例安全
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        if ( !share )
        {
            share = [[Singleton alloc] init];
        }
    });
    return share;
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}
@end
